<?php
/**
 * Created by PhpStorm.
 * User: clkj1
 * Date: 2018/7/18
 * Time: 17:15
 */

//获取要下载的文件名
if (isset($_GET['filename'])) {
    $filename = urldecode($_GET['filename']);
} else {
    exit('非法访问');
}
////设置头信息
//header('Content-Disposition:attachment;filename=' . basename($filename));
//header('Content-Length:' . filesize($filename));
////读取文件并写入到输出缓冲
//readfile($filename);

$mime = 'application/force-download';
header('Pragma: public'); // required
header('Expires: 0'); // no cache
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: ' . $mime);
header('Content-Disposition: attachment; filename="海报.jpg"');
header('Content-Transfer-Encoding: binary');
header('Connection: close');
readfile($filename); // push it out

?>